package com.xzx.annotation.bean;

import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.BeanPostProcessor;
import org.springframework.stereotype.Component;

/**
 * @author xinzhixuan
 * @version V1.0
 * @date 2018/7/14 22:35
 */
@Component
public class MyBeanPostProcessor implements BeanPostProcessor {
    @Override
    public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {
        if (beanName.equals("cat") || beanName.equals("dog") || beanName.equals("car")) {
            System.out.println("BeanPostProcessor.postProcessBeforeInitialization......");
        }
        return bean;
    }

    @Override
    public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
        if (beanName.equals("cat") || beanName.equals("dog") || beanName.equals("car")) {
            System.out.println("BeanPostProcessor.postProcessAfterInitialization......");
        }
        return bean;
    }
}
